www.gusucode.com > VC++网络版的打字软件源程序-源码程序 > VC++网络版的打字软件源程序-源码程序\code\TypeSrv V2.0\Msg.cpp

    //Download by http://www.NewXing.com
// Msg.cpp: implementation of the CMsg class.
//
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "TypeSrv.h"
#include "Msg.h"

#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

IMPLEMENT_DYNAMIC(CMsg,CObject)

CMsg::CMsg()
{
	Init();
}

CMsg::~CMsg()
{

}

void CMsg::Serialize(CArchive &ar)
{
	if(ar.IsStoring())
	{
		ar<<nFlag;

		ar<<m_strHostName;
		ar<<m_strID;
		ar<<m_strName;

		ar<<m_strQuestion;
		ar<<m_strQuestionInfo;
		ar<<m_lTestTime;
		ar<<m_nInputLanguage;

		ar<<m_nRateOfRight;
		ar<<m_nSpeedOfType;

		ar<<m_strMessage;
	}
	else
	{
		ar>>nFlag;

		ar>>m_strHostName;
		ar>>m_strID;
		ar>>m_strName;

		ar>>m_strQuestion;
		ar>>m_strQuestionInfo;
		ar>>m_lTestTime;
		ar>>m_nInputLanguage;

		ar>>m_nRateOfRight;
		ar>>m_nSpeedOfType;

		ar>>m_strMessage;
	}


}

void CMsg::Init()
{
	nFlag=0;

	m_strHostName=_T("");
	m_strID=_T("");
	m_strName=_T("");
	
	m_strQuestion=_T("");
	m_strQuestionInfo=_T("");
	m_lTestTime=0;
	m_nInputLanguage=0;

	m_nRateOfRight=0;
	m_nSpeedOfType=0;

	m_strMessage=_T("");

}


CString CMsg::GetFlagMsg()
{
	CString strMsg;
	switch(nFlag)
	{
	case CF_CLOSE:
		strMsg.Format("%s已关闭",m_strName);
		break;
	case CF_USERLOGIN:
		strMsg.Format("%s发送注册信息",m_strName);
		break;
	case CF_SENDSCORE:
		strMsg.Format("%s发送成绩",m_strName);
		break;
		
	case SF_CLOSE:
		strMsg="服务器已关闭";
		break;
	case SF_LOGINSUCCESS:
		strMsg.Format("%s注册成功",m_strName);
		break;
	case SF_LOGINFAILD:
		strMsg.Format("%s注册失败",m_strName);
		break;
	case SF_SENDQUESTION:
		strMsg.Format("服务器发送试题%s",m_strQuestionInfo);
		break;
	case SF_SENDMESSAGE:
		strMsg.Format("服务器消息:%s",m_strMessage);
		break;
	}
	return strMsg;
}